
#include <stdio.h>
#include <stdlib.h>

typedef struct Node {
    int val;
    struct Node *next;
} node;

void set_val(node *node_, int val) {
    node_->val = val;
    node_->next = node_;
}

void creat_list(node *root, const int vals[], int vals_len) {
    node *t = root;
    for (int i = 0; i < vals_len - 1; ++i) {
        t->val = vals[i];
        t->next = (node *) malloc(sizeof(node));
        t = t->next;
    }
    t->val = vals[vals_len - 1];

}

void print_list(node *node_) {
    node *t = node_;
    for (; t != NULL;) {
        printf("%d ", t->val);
        t = t->next;
    }
    printf("\n");
    //   printf("\n end \n");
}

// https://www.zhihu.com/question/41476387
void reversal_list(node **root) {

    node *prev = NULL, *curr = *root;

    while (curr != NULL) {
        node *next = curr->next;
        curr->next = prev;
        prev = curr;
        curr = next;
    }

    *root = prev;
}


void test(int a) {}

typedef struct {

}message0;

typedef struct {
int x;
}message2;
int main(int argc, char **argv) {

    message0 message01;
    message0 * p_m = &message01;
    node *root = (node *) malloc(sizeof(node));
    int vals[4] = {0, 1, 2, 3};
    creat_list(root, vals, 4);

    print_list(root);

    // 二重指针
    reversal_list(&root);


    print_list(root);
    // 如何判断一个输入是否超过  uint16_t 的最大值
    // unit_16 result  = 数字  & 65535 。如果数字 > result ，数字就是大于65535的
    u_int32_t  n = 655300;

    u_int16_t result = n & 65535;

    printf("%d ",result);



    node x;
    node y;

    node *p_x;
    node *p_y;

    p_x = &x;
    p_y = &x;

    x.val = 100;

    y = x;


    y.val = 111;



    printf("\n  x.val = %d \n",x.val);

    p_y->val = 1010;

    printf("\n  x.val = %d \n",x.val);
}